import { defineStore } from 'pinia'
import { ElLoading } from 'element-plus'
export const loadingStore = defineStore('loadingStore', {
  state: () => ({
    loading: {}
  }),
  actions: {
    openLoading() {
      this.loading = ElLoading.service({
        lock: true,
        text: '努力加载中....',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      setTimeout(() => {
        this.loading.close()
      }, 20000)
    },
    closeLoading() {
      if (this.loading) {
        this.loading.close()
      }
    }
  }
})
